Use the ConvertJsonStringToDictionary Activity
Note: Use caution when building or editing a workflow. For further advice or to arrange training, contact your professional services consultant.
The ConvertJsonStringToDictionary activity can be used to convert a JSON (JavaScript Object Notation) string and return a dictionary of string key-value pairs.
The ConvertJsonStringToDictionary activity is located in the XML/Json section of the Tribal Toolbox.
Note: The minimum requirement for the ConvertJsonStringToDictionary activity is InputString.
This activity contains the following relevant properties.
Section | This field | Holds this information... |
---|---|---|
Inputs | InputString |
The input JSON string to convert to a dictionary object. Note: The workflow will terminate if the InputString field contains a JSON string that cannot be converted to dictionary format, is in an invalid format (for example: a string with missing characters), contains an alternative format (for example: an XML string), or is blank. |
Misc | DisplayName |
The title of the activity. Note: The DisplayName property is set to ConvertJsonStringToDictionary by default. |
Outputs | OutputObject | The converted object. |
Clicking the ellipsis button adjacent to the relevant field opens the Expression Editor, where you can enter the relevant code in the Visual Basic (VB) format.
![Closed](../../../Skins/Default/Stylesheets/Images/transparent.gif)
To use the ConvertJsonStringToDictionary activity in a workflow:
-
Click the Tribal Toolbox tab in the XML/Json section of Workflow Builder.
-
Drag and drop the ConvertJsonStringToDictionary activity into the desired location within the Sequence panel. In this example, ConvertJsonStringToDictionary is followed by TrackingMessageActivity so that the output can be viewed.
-
Enter values for the InputString (for example: "{'1':'One','2':'Two','3':'Three'}") and OutputObject (for example: dictionary) fields and add a name for the activity to the DisplayName field. Click the ellipsis button adjacent to the relevant fields to open the Expression Editor.
Note: An exclamation mark symbol indicates a warning. Refer to Use the Warnings Panel for further information.
-
Enter values for TrackingMessageActivity fields, Key (for example: "Dictionary") and TrackingMessage (for example: string.Join(","dictionary) ) fields and add a name for the activity to the DisplayName field.
-
Click Save.
You can now trigger the workflow and use the User Tracking tab to ensure that the JSON string is converted to dictionary of string key-value pairs (for example: "{'1':'One','2':'Two','3':'Three'}" is converted to [1, One], [2, Two], [3, Three]).